/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.pa165.machineryrental.service;

import cz.muni.fi.pa165.machineryrental.dto.RevisionDTO;
import java.util.Date;
import java.util.List;

/**
 *
 * @author David Katuscak, 359273
 */
public interface RevisionService {

    /**
     * Reads entity with given identifier from database.
     *
     * @param id Represents unique identifier of revision instance.
     * @return Revision, which has given identifier
     * @throws IllegalStateException Throws if factory is not initialized.
     */
    RevisionDTO getById(long id);

    /**
     * Persists given revision instance to database.
     *
     * @param revision Represents revision to persist to database.
     * @throws IllegalArgumentException Throws if given revision is null.
     * @throws IllegalStateException Throws if factory is not initialized.
     */
    void create(RevisionDTO revision);

    /**
     * Updates existing instance with given instance in database.
     *
     * @param revision Given Revision instance to update.
     * @throws IllegalArgumentException Throws if given revision is null.
     * @throws IllegalStateException Throws if factory is not initialized.
     */
    void update(RevisionDTO revision);

    /**
     * Removes given revision from database if exists.
     *
     * @param revision Revision to remove from database.
     * @throws IllegalArgumentException Throws if given revision is null.
     * @throws IllegalStateException Throws if factory is not initialized.
     */
    void remove(RevisionDTO revision);

    /**
     * Load all existing revisions from database and returns them as list.
     *
     * @return All existing revisions from database.
     * @throws IllegalStateException Throws if factory is not initialized.
     */
    List<RevisionDTO> findAll();

    /**
     * Returns list of revisions in given interval.
     *
     * @param start Start date and time from which we want return revisions.
     * @param end End date and time to which we want return revisions.
     * @throws IllegalArgumentException Throws if given start date is null.
     * @throws IllegalArgumentException Throws if given end date is null.
     * @throws IllegalStateException Throws if factory is not initialized.
     * @return List of revisions in given interval.
     */
    List<RevisionDTO> findByInterval(Date startDate, Date endDate);
}
